<template>
	<view>
		<view class="account" v-if="status == 0">
			<view class="pick-left">
				复投金额
			</view>
			<view class="pick-right">
				<view class="money-body">
					<!-- <view class="mony-item" v-for="(item,key) in moneys"><text :class="money_index == key ? 'active' : ''" @tap="selectMoney(key)">{{item}}</text></view> -->
					<input type="number" placeholder="请输入复投金额" v-model="price"/>
				</view>
			</view>
		</view>
		<!-- 账户选择 -->
		<view class="account" v-if="status == 1">
			<view class="pick-left">
				选择金额
			</view>
			<view class="pick-right">
				<picker type="select" :value="index" :range="account" @change="selectAccount">
					<view class="uni-input">{{account [account_index]}}</view>
				</picker> 
			</view>
		</view> 
		<!-- 账户选择 -->
		<view class="account" v-if="status == 2">
			<view class="pick-left">
				选择金额
			</view>
			<view class="pick-right">
				<picker type="select" :value="index" :range="account" @change="selectAccount">
					<view class="uni-input">{{account [account_index]}}</view>
				</picker> 
			</view>
			<view class="bar-msg">*出局后复投需要扣除50%的余额50%的种子币</view>
		</view> 
		<view class="account">
			<view class="pick-left">
				交易密码
			</view>
			<view class="pick-right">
				<input type="password" placeholder="请输入交易密码" v-model="pwd1"/>
			</view>
		</view>
		<view class="account">
			<button @tap="submit">立即复投</button>
		</view>
	</view>
</template>

<script>
	export default{
		data(){
			return{
				pwd1:'',
				price : '',
				account_index : 0,
				account:[3000,10000,30000,50000],
				status : 0,
			}
		},
		onLoad() {
			this.getData();
		},
		methods:{
			getData(){
				this.ajax('user/states',{
					data:{},
					success:(res) => {
						res = res.data;
						this.status = res.info;
					}
				});
			},
			selectMoney(key){
				this.money_index = key;
			},
			selectAccount(e){
				this.account_index = e.target.value;
				this.price = this.account[this.account_index];
			},
			submit(){
				if(!this.price)return this.toasts('请输入复投金额');
				if(!this.pwd1)return this.toasts('请输入交易密码');
				this.ajax('user/futou',{
					data:{
						price : this.price,
						pwd1 : this.pwd1,
					},
					success:(res) => {
						res = res.data;
						this.toasts(res.info);
						if(res.status) {
							this.price = '';
							this.pwd1 = '';
						}
					}
				});
			}
		}
		
		
	}
</script>

<style>
	.mony-item{float: left;width: 25%;text-align: center;}
	.mony-item > text{padding:5upx 20upx;border:1upx solid #409EFF;font-size: 25upx;border-radius: 5upx;color:#666666}
	.mony-item .active{color:#FFFFFF;background: #409EFF;}
	.account{width: calc(100% - 40upx);padding:20upx;overflow: hidden;background: #FFFFFF;}
	.account >view{float:left;font-size: 35upx;}
	.pick-left{width: 140upx;}
	.pick-right{width: calc(100% - 150upx);margin-left: 10upx;color:#666666}
	.account button{height:80upx;line-height: 80upx;background: #409EFF;color:#FFFFFF;border:none}
	.bar-msg{margin-top: 10upx;font-size: 20upx;color:#DD2222;}
</style>
